package com.imooc.user.service;


import com.imooc.user.pojo.UserAddress;
import com.imooc.user.pojo.bo.AddressBo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: 顾志杰
 * @Date: 2019/11/13
 * @Time: 15:10
 */
@FeignClient("foodie-user-service")
@RequestMapping("address-api")
public interface AddressService {
    /**
     * 根据登录人查询收货地址列表
     * @param userId
     * @return
     */
    @GetMapping("addressList")
    List<UserAddress> queryAll(@RequestParam("userId") String userId);

    /**
     * 新增收货地址
     * @param addressBo
     */
    @PostMapping("address")
    void addNewUserAddress(@RequestBody AddressBo addressBo);

    /**
     * 修改收货地址
     * @param addressBo
     */
    @PutMapping("address")
    void updateUserAddress(@RequestBody AddressBo addressBo);


    /**
     * 修改收货地址
     * @param userid
     * @param addressId
     */
    @DeleteMapping("address")
    void deleteUserAddress(@RequestParam("user") String userid,
                           @RequestParam("addressId") String addressId);


    /**
     * 设置为默认地址
     * @param userid
     * @param addressId
     */
    @PostMapping("setDefalutAddress")
    void setDefalutUserAddress(@RequestParam("user") String userid,
                               @RequestParam("addressId") String addressId);

    /**
     * 根据用户id与地址id获取地址信息
     * @param userId
     * @param addressId
     */
    @GetMapping("queryAddress")
    UserAddress queryUserAddress(@RequestParam("user") String userId,
                                 @RequestParam(value = "addressId",required = false) String addressId);
}
